<?php

if (isset($_POST)) {
	if(isset($_REQUEST['folder_id'])) {
		$db->delete('cms_files', array($db->quoteInto("folder_id=?", $_REQUEST['folder_id']),  $db->quoteInto("site_id=?", $site['id'])));
	} elseif ($image_id = $path[4] and ctype_digit($image_id)) {
		$db->delete('cms_files', array($db->quoteInto("id=?", $image_id),  $db->quoteInto("site_id=?", $site['id'])));
	}
}

if (!(isset($_SERVER['HTTP_X_REQUESTED_WITH']) and $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') and isset($_SERVER['HTTP_REFERER'])) {
	header("Location: {$_SERVER['HTTP_REFERER']}");
}
